﻿using ServiceStack.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Auth 的摘要说明
/// </summary>
public static class Auth
{
    public static bool UserLogined(string uid, string kid)
    {
        if (string.IsNullOrEmpty(uid) || string.IsNullOrEmpty(kid))
        {
            return false;
        }
        else
        {
            using (IRedisClient redis = RedisClientPool.GetReadOnlyRedisClient())
            {
                if (redis==null)
                {
                    return true;
                }
                else
                {
                    if (redis.ContainsKey(uid))
                    {
                        if (redis.GetValueFromHash(uid, "kid") != kid)
                        {
                            return false;
                        }
                    }
                    else
                    {
                        return false;
                    }
                }
            }
        }
        return true;
    }
}